#include "ET++.ph"
#ifdef __GNUG__
#pragma implementation
#endif

#include "DataListView.h"
#include "Class.h"
#include "Math.h"
#include "Data.h"

DataListView::DataListView(int id, EvtHandler *eh, int w, SeqCollection *c)
						: ObjGridView(id, eh, w, c)
{
}

Metric DataListView::ObjCellSize(const Point &cell, Object *op)
{
	Font *f= GetCellAttributes(cell)->font;
	Data *data= (Data*) op;
	return Metric(Math::Max(f->Width((byte*) data->ShortName())+22, width),
						f->Spacing(), f->Ascender());
}

void DataListView::DrawObjCell(const Point &cell, Object *op,
				const Rectangle &r, const Rectangle&, bool)
{
	CellAttributes *ca= GetCellAttributes(cell);
	Data *data= (Data*) op;

	Point p(r.origin);
	p.x+= 22;
	p.y+= ca->font->Ascender();
	GrShowString(ca->font, ca->ink, p, (byte*) data->ShortName());

	Bitmap *bm= data->GetBitmap();
	if (bm) {
		Rectangle br(r.origin, bm->Size());
		br.origin.x+= (22-br.extent.x)/2;
		br.origin.y+= (r.extent.y-br.extent.y)/2;
		GrPaintBitMap(br, bm, ca->ink);
	}
}

